//src/chat/entities/chat.entity.ts
import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class Chat {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'sender_id', comment: '发送者id， 模型的id默认为0' })
  senderId: string;

  @Column({ name: 'receiver_id', comment: '接受者id， 模型的id默认为0' })
  receiverId: string;

  @Column({ type: 'text' })
  message: string;

  @Column({
    type: 'text',
    comment: '每条聊天记录(主要针对模型返回的内容)涉及的溯源文件数组(json格式)',
  })
  links: string;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  timestamp: Date;

  @CreateDateColumn({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP(6)',
  })
  created_at: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP(6)',
    onUpdate: 'CURRENT_TIMESTAMP(6)',
  })
  updated_at: Date;
}
